﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Shapes;

namespace SnowLotus.Canvas
{
    public class SL2Ellipse : SL2Base
    {
        private Ellipse mellipse;
        private TranslateTransform translateTransform;
        private double mr = 0;

        public Ellipse Shape
        {
            get { return mellipse; }
        }

        public SL2Ellipse(double centerx = 0, double centery = 0, double r1 = 0,double r2=0, Brush stroke = null)
        {
            mellipse = new Ellipse();
            if (r2 == 0)
            {
                r2 = r1;
            }
          

            mellipse.Width = r1 * 2;
            mellipse.Height = r2 * 2;
            mr = r1;

            translateTransform = new TranslateTransform();
            translateTransform.X = centerx - r1;
            translateTransform.Y = centery - r2;
            mellipse.RenderTransform = translateTransform;


            if (stroke != null)
            {
                mellipse.Stroke = stroke;
            }
            else
            {
                mellipse.Stroke = Brushes.Black;
            }


            Manager.AddShape(mellipse);

        }

        /// <summary>
        /// move circle ok,ellispe will move error
        /// </summary>
        /// <param name="centerx"></param>
        /// <param name="centery"></param>
        public override void move(double centerx, double centery)
        {
            
            translateTransform.X = centerx -mr;
            translateTransform.Y = centery -mr;

            // 更新 Ellipse 的 RenderTransform
            mellipse.RenderTransform = translateTransform;

        }


       




    }
}
